package com.hy.controller;

import com.aliyuncs.exceptions.ClientException;
import com.hy.service.NoteService;
import com.hy.utils.HY_Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 阿里云 手机短信验证码
 */
//@CrossOrigin
@RestController
@RequestMapping("/hy-frontuser-provider/note")
public class Note_CodeController {

    //短信 - 服务
    @Autowired
    private NoteService nts;

    /**
     * 发送短信 - 奕靜
     * @param phone
     * @return
     */
    @RequestMapping("/sendCode.do")
    public HY_Result sendCode(@RequestParam String phone) throws ClientException {
        return nts.sendCode(phone);
    }

    /**
     * 发送验证码 - 华子
     * @param phone
     * @return
     */
    @RequestMapping("/send.action")
    public HY_Result sendSms(@RequestParam String phone) {
        return nts.sendSms(phone);
    }

    /**
     * 短信验证码  验证
     *
     * @param phone             手机号
     * @param verification_code 验证码
     * @return
     */
    @RequestMapping("/noteVerify.action")
    public HY_Result noteVerify(@RequestParam String phone, @RequestParam String verification_code) {
        return nts.checkVerification(phone,verification_code);
    }

}
